package main.od;

import java.util.*;

public class MemoryTest {
    static final String REQUEST = "REQUEST";
    static final String RELEASE = "RELEASE";
    static final String ERROR = "ERROR";
    static final int MAX = 100;
    static int lastHeadAddress = 0;
    static Map<Integer,Integer> map = new TreeMap<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.nextLine());
        String[][] commandArr = new String[N][2];
        for (int i = 0;i < N;i++){
            commandArr[i] = scanner.nextLine().split("=");
        }
        for (int i = 0;i < N;i++){
            int value = Integer.parseInt(commandArr[i][1]);
            if (commandArr[i][0].startsWith(REQUEST)){
                if (value > MAX || value <= 0){
                    System.out.println(ERROR);
                    return;
                }
                request(value);
            }else if (commandArr[i][0].startsWith(RELEASE)){
                map.remove(value);
            }else {
                System.out.println(ERROR);
            }
        }
        System.out.println(lastHeadAddress);
    }
    public static void request(int value){
        int freeAddress = 0;
        if (map.isEmpty()){
            map.put(0,value);
        }else {
            List<Integer> headAddressList = new ArrayList<>(map.keySet());
            for (Integer headAddress : headAddressList){
                if (headAddress - freeAddress >= value){
                    map.put(freeAddress,freeAddress + value);
                }else {
                    freeAddress = map.get(headAddress);
                }
            }
        }
        if (MAX - freeAddress >= value){
            map.put(freeAddress,freeAddress + value);
        }else {
            System.out.println("-1");
        }
        lastHeadAddress = freeAddress;
    }

}